package com.lizardmind.haofudoctor.ui.studio

import android.os.Bundle
import android.support.v7.widget.LinearLayoutManager
import android.view.View
import com.lcodecore.tkrefreshlayout.RefreshListenerAdapter
import com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout
import com.linxiao.framework.activity.BaseActivity
import com.linxiao.framework.adapter.BaseAdapter
import com.linxiao.framework.util.getDataBinding
import com.linxiao.framework.util.toasts
import com.lizardmind.haofudoctor.R
import com.lizardmind.haofudoctor.databinding.ActivitySimpleListBinding
import com.lizardmind.haofudoctor.databinding.ItemRecommendPeerBinding
import com.lizardmind.haofudoctor.other.DoctorBean
import kotlinx.android.synthetic.main.activity_simple_list.*
import kotlinx.android.synthetic.main.include_title_text.*
import org.jetbrains.anko.sdk25.coroutines.onClick

/**
 * Created by Administrator on 2017/12/20.
 * 推荐同行activity
 */
class RecommendPeerActivity:BaseActivity() {

    val list= arrayListOf(
            DoctorBean("1","万恒","12345678900","aaa",1,"从事","副主任医师","四川省成都市",
                    "成都第十人民医院","aaaaaaaaaaa","1970-10-10","aaaaaaa","大家好",
                    "骨科，推拿","技术很好"),
            DoctorBean("1","张燕","12345678900","aaa",2,"从事","主任医师","四川省成都市",
                    "成都第十人民医院","aaaaaaaaaaa","1970-10-10","aaaaaaa","大家好",
                    "骨科，推拿","技术很好")
    )

    val adapter by lazy { BaseAdapter<DoctorBean,ItemRecommendPeerBinding>(R.layout.item_recommend_peer,list) }
    val binding by lazy { getDataBinding<ActivitySimpleListBinding>(R.layout.activity_simple_list) }
    override fun onCreatRootView(): View? {
        return binding.root
    }

    override fun onInitView(savedInstanceState: Bundle?) {
        imgLeft.setImageResource(R.mipmap.back)
        imgLeft.onClick { finish() }
        titleText.text="推荐同行"

        recyclerView.layoutManager=LinearLayoutManager(this)
        recyclerView.adapter=adapter

        adapter.onBind { itemBingding, position, data ->
            itemBingding.tvRecommend.onClick {
                toasts("推荐")
            }
        }

        refreshLayout.setOnRefreshListener(object :RefreshListenerAdapter(){
            override fun onRefresh(refreshLayout: TwinklingRefreshLayout?) {
                super.onRefresh(refreshLayout)
            }
            override fun onLoadMore(refreshLayout: TwinklingRefreshLayout?) {
                super.onLoadMore(refreshLayout)
            }
        })
    }
}